package context

import (
	"sync"
	"xian-server/lib/cfg"
	"xian-server/lib/context"
	"xian-server/lib/database"
)

var (
	Ctx         *Context
	onceContext sync.Once
)

type Context struct {
	Connection Connection
}

// UseContext 获取上下文
func UseContext() *Context {
	onceContext.Do(func() {
		cfg.Setup()
		database.Setup()
		Ctx = &Context{Connection: &MysqlConnection{
			DB: context.DB,
		}}
	})
	return Ctx
}
